package dm.ast.model.gen.factory;

import dm.ast.DmSelect;
import dm.sql.comp.ASTComplex;

/**
 * @author weihuixin
 * @date 2024/2/29
 * @Description
 */
public class ComplexityModel {
    //由于后期在复杂模块化过程中,可能出现宽度用完的情况
    //所以此时count可自行修改为较小的数目。宽度和深度为0的情况均是不合法的
    public int count = DmSelect.SUBCLAUSE_CNT;

    //in左边操作数的列数
    public int inLeft = 0;

    //模板权重比例,默认为1
    //数值可以为从0开始的整数。越大表示权重比例越大。0表示权重比例为0,即不会出现
    public int weight = 1;

    public ASTComplex[] comps;

    private void init(){
        comps = new ASTComplex[count];
        for (int i = 0; i < count; i++) {
            comps[i] = new ASTComplex();
        }
    }

    public ComplexityModel(){
        init();
    }

    public ComplexityModel(int count){
        this.count = count;  //field
        init();
    }

    public void setTargetComp(int targetW,int targetD){
        comps[DmSelect.INDEX_HINT].wid_t = targetW;
        comps[DmSelect.INDEX_HINT].dep_t = targetD;
    }

    public void setInLeft(int left){
        this.inLeft = left;
    }

    public int getInLeft(){
        return inLeft;
    }
}
